package random

import (
	"fmt"
	"math/rand"
	"strconv"
	"sync"
	"time"
)

var (
	randUtilTemp *randUtil
	randUtilOnce sync.Once
)

type randUtil struct{}

func New() *randUtil {
	randUtilOnce.Do(func() {
		randUtilTemp = &randUtil{}
	})
	return randUtilTemp
}

func (m *randUtil) GetRand(size int) string {
	return fmt.Sprintf("%0"+strconv.Itoa(size)+"v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
}
